import { Card,Table} from 'antd'
import React from 'react'
import './TodoPortal.less'
import moment from 'moment'
import {history} from 'umi'

const TodoPortal = ({ loading, noticeList }) => {

  const routeJump = (type) =>{
    if(type === 3){  //新员工转正
      history.push('/personnel/turnPositive');
    }else if(type === 7){  //管理晋级转正
      history.push('/personnel/manage');
    }else if(type === 8){ //360评分
      history.push('/personnel/score');
    }
  };

  const columns = [
    {
      title: '序号',
      render:(text,record,index)=>`${index+1}`,
      hideInSearch: true,
    },
    {
      title: '待办事件',
      dataIndex: 'title',
      key: 'title',
    },
    {
      title: '消息日期',
      dataIndex: 'createTime',
      key: 'createTime',
      render: (text) => {
        return text ? moment(text).format('YYYY-MM-DD') : ''
      },
    },
  ];

  return (
    <Card
      loading={loading}
      bordered={false}
      title="我的待办"
      className="todo-portal"
      style={{height: '100%'}}
    >
      <Table dataSource={noticeList} style={{cursor:'pointer'}} columns={columns} rowKey="id" onRow={record => {return {onClick: (() => routeJump(record.type))}}}/>
    </Card>
  )
};

export default TodoPortal
